home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / commio0b.zip / TEST.PAS < prev    next >
Pascal/Delphi Source File  |  1996-05-20  |  5KB  |  147 lines

  1. {$M $4000,0,655350}
  2. {$X+,S+,R+}     {S,R should be turned off when compiling a final copy}
  3. program test;
  4. {
  5.       This is just a small testing program for the COMMIO DOOR Kit.  It shows
  6.       an example of how to setup the SIO routines, so you can communicate
  7.       with the remote user.
  8.       You can use this file as a basis to help you create your first door.
  9. }
  10. uses _exit, cmdline, crt, dos, mtask, commio, doorio, iniunit,
  11.      dfunit, taskunit;
  12.  
  13. var
  14.   ch:char;
  15.   i:integer;
  16.   v:Tinival;
  17.   lastkey:boolean;
  18.  
  19. {───────────────────────────────────────────────────────────────────────────}
  20. Procedure init;
  21. begin
  22.   if paramstr(1)='' then terminate('SYSOP: you must put the "path\filename.ext" for the INI file on'#13#10+
  23.                                    '       the command line.');
  24.   {v- Read in INI file. }
  25.   i:=OpenIni(paramstr(1));
  26.   if i=ErrOk then with door do begin
  27.     i:=GetIniVal('USEFOSSIL',Iniboolean,v);
  28.     if v.bool then WhichIO:=fossilIO else WhichIO:=InternalIO;
  29.     i:=GetIniVal('NODE',Inibyte,v);
  30.     if i=ok then node:=v.b else node:=1;{ else terminate('"NODE" keyname not found in INI file!');}
  31.     i:=GetIniVal('COMPORT',Inibyte,v);
  32.     if i=ok then comport:=v.b else terminate('SYSOP: "COMPORT" keyname not found in INI file!');
  33.     i:=GetIniVal('BAUDRATE',Inilongint,v);
  34.     if i=ok then baudrate:=v.li else terminate('SYSOP: "BAUDRATE" keyname not found in INI file!');
  35.     i:=GetIniVal('USEFIFOS',IniBoolean,v);
  36.     if i=ok then ChangeFIFO(comport,v.bool);
  37.     i:=GetIniVal('IRQ',Inibyte,v);
  38.     if i=ok then if (v.b>0)and(v.b<16) then begin IRQ:=v.b; ChangeIRQ(comport,IRQ); end
  39.       else terminate('SYSOP: Invalid IRQ given in INI file!');
  40.     i:=GetIniVal('WORDSIZE',Inibyte,v);
  41.     if i=ok then wordsize:=v.b else wordsize:=8;
  42.     i:=GetIniVal('PARITY',Inistring,v);
  43.     if i=ok then parity:=v.st[1] else parity:='N';
  44.     i:=GetIniVal('STOPBITS',Inibyte,v);
  45.     if i=ok then stopbits:=v.b else stopbits:=1;
  46.     i:=GetIniVal('INBUFSIZE',IniInteger,v);
  47.     if i=ok then inbufsize:=v.i else inbufsize:=512;
  48.     i:=GetIniVal('OUTBUFSIZE',IniInteger,v);
  49.     if i=ok then outbufsize:=v.i else outbufsize:=1024;
  50.   end else terminate('SYSOP: INI file "'+paramstr(1)+'" not found!');
  51.   CloseIni;
  52.  
  53.   {v- Pharse command line. }
  54.   if ScanParam('/L',false) then door.comport:=0; {local mode}
  55.  
  56.   If not InitComport
  57.     then terminate('SYSOP: No carrier detected on COM'+istr(door.comport,0)+'!')
  58.     else door.online:=true;
  59.  
  60. {  if C_FifoOK[door.comport]
  61.     then writeln('FIFO''s found!')
  62.     else writeln('FIFO''s NOT found!');{}
  63.  
  64.   HideStatusBar;
  65.   ShowStatusBar;
  66.   InstallAllTasks;
  67. end;
  68. {───────────────────────────────────────────────────────────────────────────}
  69.  
  70. var
  71.   h,m,s,hs:word;
  72.   f:text;
  73.   st:string;
  74.   c:char;
  75.   l:longint;
  76.   t:byte;
  77.   x,y:byte;
  78. begin
  79.   init;
  80.  
  81.   textattr:=7;
  82.   sioclrscr;
  83.  
  84.   InitVirtScr; {initialize virtual screen}
  85.   putstr('Θ|0Θ3ΘbA simple test program written by Lief O''Pardy to test his new COMM routines!!Θ|0Θ.');
  86.   putstr('Θ3ΘaThis is a basic CHAT program.  Supporting different color text for each user.Θ.Θ|0');
  87.   putstr('Θ.Θ3The sysop should try to use his local statusbar commands, at the same time theΘ.');
  88.   putstr('Θ3user types in stuff.  They should both work at the same time, w/o messing upΘ.');
  89.   putstr('Θ3anything the remote user is doing!Θ.');
  90.   putstr('Push <esc> to exit.Θ.Θ.');
  91.  
  92. {  MACROSTR:='^~J^~a^~s^~o^~n Morriss';{}
  93.   setcolor(15,0); lastkey:=true;
  94.   repeat
  95.     ch:=sioreadkey;
  96. {    if door.online=false then break;{}
  97.  
  98.     if (door.localkey)and(not lastkey) then begin
  99.       lastkey:=true;
  100.       setcolor(15,0);
  101.     end else if (not door.localkey)and(lastkey) then begin
  102.       lastkey:=false;
  103.       setcolor(3,0);
  104.     end;
  105.  
  106.     case ch of
  107.       #8  : siowrite(#8' '#8);
  108.       #13 : siowriteln('');
  109.       #27 : {quit};
  110.       '8','H' : siocursorup(1);     {siogotoxy(virtx,virty-1);}
  111.       '2','P' : siocursordown(1);   {siogotoxy(virtx,virty+1);}
  112.       '4','K' : siocursorleft(1);   {siogotoxy(virtx-1,virty);}
  113.       '6','M' : siocursorright(1);  {siogotoxy(virtx+1,virty);}
  114.       '|' : begin
  115.         t:=textattr;
  116.         DisplayAnsifile('test.ans',25);
  117.         {^ this still does'nt do correct page breaks. it varies for each ansi.
  118.            i have an idea of how to fix it, and i will sooner or later}
  119.         textattr:=t;
  120.       end;{}
  121.       '!' : drawscr(virtscr,1,1,80,25);  {refresh the screen}
  122.       {^- make sure you read the TODO.LST about the virtual routines}
  123.       '~' : begin
  124.         setcolor(7,0);
  125.         door.usecolor:=not door.usecolor;
  126.         if door.usecolor then siowriteln(#13#10'COLOR is now ON.')
  127.           else siowriteln(#13#10'COLOR is now OFF.')
  128.       end;{}
  129. {      '@' : begin kickedout:=true; door.online:=false; end;}
  130.       else siowritec(ch);
  131.     end;
  132.  
  133. {    writestr(60,1,'WhereX: '+istr(virtx,2)+' ');
  134.     writestr(60,2,'WhereY: '+istr(virty,2)+' ');
  135. {    x:=wherex; y:=wherey;
  136.     gotoxy(60,1);
  137.     write('CTS stat:',CTSstat(door.comport));
  138.     gotoxy(60,2);
  139.     write('RTS stat:',RTSstat(door.comport));
  140.     gotoxy(60,3);
  141.     write('DSR stat:',DSRstat(door.comport));
  142.     gotoxy(x,y);{}
  143.   until (ch=#27);
  144.  
  145. {  freevirtscr;{called automatically}
  146. {  DeInitComport;{this is done automatically after the program halts!}
  147. end.